package com.alex.xmlyfm.tasks;

import com.alex.mylibrary.tasks.BaseTask;
import com.alex.mylibrary.tasks.TaskCallBack;
import com.alex.mylibrary.tasks.TaskResult;
import com.alex.xmlyfm.Constants;
import com.alex.xmlyfm.client.ClientAPI;
import com.alex.xmlyfm.entities.EntityParseUtil;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by
 * Author: alex
 * Email:
 * Date: 15-10-20.
 */
public class DiscoverRecommendTask extends BaseTask {

//    private TaskCallBack callBack;

    public DiscoverRecommendTask(TaskCallBack callBack) {
        super(callBack);
    }


    @Override
    protected TaskResult doInBackground(String... params) {
        TaskResult ret = new TaskResult();

        ret.action = Constants.TASK_ACTION_RECOMMENDS;
        JSONObject jsonObject = ClientAPI.getDiscoverRecommend("and-f6", true, true);
        if (jsonObject != null) {
            try {
                ret.resultCode = jsonObject.getInt("ret");
                // 解析数据
                ret.data = EntityParseUtil.parseDiscoverRecommends(jsonObject);
                ret.datas = new Object[2];
                ret.datas[0] = EntityParseUtil.parseFocusImages(jsonObject);

            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        return ret;
    }



}
